<html>
	<head>
	<link rel="stylesheet" href="resources/redwood/player.css">
	<link rel="preload" href="resources/promise-queues.js" as="script">
	<link rel="preload" href="resources/base.js" as="script">
	<script src="resources/promise-queues.js"></script>
	<script src="resources/base.js"></script>
	<title>Project Redwood</title>
	</head>
	<body style="margin: 0px; background-color: black; color: white;">
		<div id="player-api">
			<script >if (window.ytcsi) {window.ytcsi.tick("cfg", null, '');}</script>
		</div>
	</body>
	<script src="resources/redwood/redwood_preprocessor.js"></script>
	<script src="resources/redwood/youtube_base.js"></script>
	<script src="resources/redwood/youtube_embed.js"></script>
	<script src="resources/redwood/youtube_www_embed_player.js"></script>
	<script src="resources/redwood/redwood.js"></script>
	<script>
		(function() {
			if (window.location.toString().contains("file:///")) {
				console.warn("nTube was opened locally, not extracting.");
				return;
			}
			const VIDEO_ID = getQueryVariable("v");
			if (VIDEO_ID == null || VIDEO_ID.length == 0) {
				alert("nTube encountered an error.\r\nError: VIDEO_ID is null or blank!");
				return;
			}
			var PREFER_QUALITY = 720;
			var url = "/api/get_video";
			url += "?v=" + VIDEO_ID;
			url += "&prefer=" + PREFER_QUALITY;
			url += "&useDJSMuxingViaMPD";
			url += "&av1";
			url += "&allowWebM";
			request(url, null, function(exception) {
				console.error(exception);
				alert("nTube failed to talk with it's backend.\r\nCheck your browser's console for more information.");
			}, function(data) {
				var jsonObject = JSON.parse(data);
				try {
					document.title = jsonObject.metadata.title + " - Project Redwood for nTube."
				}catch (e) {}
				window.ytObject = Redwood.initPlayer(VIDEO_ID, jsonObject);
			});
		})();
	</script>
</html>